import 'common_mode.dart';

enum MessageType { text, time, image, video, sheet, system, narration }

class ChatUser2 {
  final String id; // 用户 ID
  final String nickname; // 昵称
  final String avatarUrl; // 头像 URL

  ChatUser2({
    required this.id,
    required this.nickname,
    required this.avatarUrl,
  });
}

class ChatMessage2 {
  bool isMine = false;
  final ChatUser2 user;
  final DateTime timestamp;
  MessageType messageType;
  Map<String, dynamic>? customProperties;
  bool? isMarkdown;
  String text = '';
  List<dynamic> buttonList = [];
  List<ChatMedia2> medias = [];

  ChatMessage2({
    required this.user,
    required this.timestamp,
    this.messageType = MessageType.text,
  });
}

class QuickReply2 {
  /// Title of the quick reply,
  /// it's what will be visible in the quick replies list
  String title;

  /// A list of custom properties to extend the existing ones
  /// in case you need to store more things.
  /// Can be useful to extend existing features
  Map<String, dynamic>? customProperties;

  QuickReply2({
    required this.title,
    this.customProperties,
  });
}

class ChatMedia2 {
  String url;
  MediaType2 type;
  Map<String, dynamic>? customProperties;

  ChatMedia2(
    this.url,
    this.type,
  );
}

class MediaType2 {
  const MediaType2._internal(this._value);
  final String _value;

  @override
  String toString() => _value;

  static MediaType2 parse(String value) {
    switch (value) {
      case 'image':
        return MediaType2.image;
      case 'video':
        return MediaType2.video;
      case 'audio':
        return MediaType2.audio;
      case 'file':
        return MediaType2.file;
      default:
        throw UnsupportedError('$value is not a valid MediaType');
    }
  }

  static const MediaType2 image = MediaType2._internal('image');
  static const MediaType2 video = MediaType2._internal('video');
  static const MediaType2 audio = MediaType2._internal('audio');
  static const MediaType2 file = MediaType2._internal('file');
}
